<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<script>
	function inputFocus(){
		document.getElementById('nameTxt').focus();
	}
</script>
</h:head>
<h:body>
	<h:form prependId="false">
		<h:dataTable id="dataTable" value="#{bookManagementBean.books}" var="book">
			<h:column>
				<f:facet name="header">ID</f:facet>
				#{book.id}
			</h:column>
			<h:column>
				<f:facet name="header">Title</f:facet>
				#{book.title}
			</h:column>
		</h:dataTable>
		<h:panelGroup>
			<h:outputLabel for="nameTxt" value="Title"/>
			<h:inputText id="nameTxt" value="#{bookManagementBean.title}" required="true" label="Title"/>
			<h:commandButton value="Save" actionListener="#{bookManagementBean.addBook}">
				<f:ajax execute="nameTxt" render="@form"/>
			</h:commandButton>
		</h:panelGroup>
		<h:message for="nameTxt" showSummary="false" errorStyle="color:red"/>
		<script>
			inputFocus();
		</script>
	</h:form>
</h:body>
</html>